import request from '@/utils/request'

// 查询题目列表
export function listQuestion(query) {
  return request({
    url: '/exam/question/list',
    method: 'get',
    params: query
  })
}

// 查询题目所有列表
export function listAllQuestion(query) {
  return request({
    url: '/exam/question/listAll',
    method: 'get',
    params: query
  })
}

// 查询题目详细
export function getQuestion(questionId) {
  return request({
    url: '/exam/question/getInfo/' + questionId,
    method: 'get'
  })
}

// 获取题目详细信息（包含选项、答案、解析等）
export function getQuestionDetailInfo(questionId) {
  return request({
    url: '/exam/question/getDetailInfo/' + questionId,
    method: 'get'
  })
}

// 新增题目
export function addQuestion(data) {
  return request({
    url: '/exam/question/add',
    method: 'post',
    data: data
  })
}

// 修改题目
export function updateQuestion(data) {
  return request({
    url: '/exam/question/edit',
    method: 'post',
    data: data
  })
}

// 删除题目
export function delQuestion(questionId) {
  return request({
    url: '/exam/question/remove/' + questionId,
    method: 'get'
  })
}

// 导入题目数据
export function importData(file, updateSupport) {
  const formData = new FormData()
  formData.append('file', file)
  formData.append('updateSupport', updateSupport)
  
  return request({
    url: '/exam/question/importData',
    method: 'post',
    data: formData,
    headers: {
      'Content-Type': 'multipart/form-data'
    }
  })
}
